<template>
  <div class="home-page">
    <!-- 搜索栏 -->
    <div class="search-bar">
      <el-input
        v-model="searchText"
        placeholder="搜索歌曲或歌手"
        prefix-icon="Search"
        class="search-input"
      />
    </div>

    <!-- 分类按钮 -->
    <div class="category-tabs">
      <div
        v-for="category in categories"
        :key="category.id"
        :class="['category-btn', { active: activeCategory === category.id }]"
        @click="activeCategory = category.id"
      >
        {{ category.name }}
      </div>
    </div>

    <!-- 歌曲列表 -->
    <div class="song-list">
      <div
        v-for="(song, index) in songList"
        :key="song.id"
        class="song-item"
      >
        <div class="song-rank">{{ song.rank }}</div>
        <div class="song-info">
          <div class="song-title">{{ song.title }}</div>
          <div class="song-artist">{{ song.artist }}</div>
        </div>
        <div class="song-action">
          <el-icon 
            :class="['star-icon', { favorite: song.isFavorite }]"
            @click="toggleFavorite(song)"
          >
            <Star />
          </el-icon>
        </div>
      </div>
    </div>

    <!-- 底部播放器控制条 -->
    <div class="bottom-player">
      <div class="player-bar"></div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { Search, Star } from '@element-plus/icons-vue'

const searchText = ref('')
const activeCategory = ref(1)

const categories = [
  { id: 1, name: '全部歌曲' },
  { id: 2, name: '热门歌曲' },
  { id: 3, name: '女生歌曲' },
  { id: 4, name: '男生歌曲' }
]

const songList = ref([
  { id: 1, rank: 50, title: '起风了', artist: '邓紫棋', isFavorite: false },
  { id: 2, rank: 49, title: '光年之外', artist: '邓紫棋', isFavorite: false },
  { id: 3, rank: 48, title: '句号', artist: '阿光', isFavorite: false },
  { id: 4, rank: 47, title: '这就是爱', artist: '张杰', isFavorite: false },
  { id: 5, rank: 46, title: '晴天', artist: '周杰伦', isFavorite: false },
  { id: 6, rank: 45, title: '最好的我们', artist: '王源', isFavorite: false },
  { id: 7, rank: 44, title: '生而为海', artist: '黄霄云', isFavorite: false },
  { id: 8, rank: 43, title: '无人之岛', artist: '任然', isFavorite: false },
  { id: 9, rank: 42, title: '我们的歌', artist: '王力宏', isFavorite: false }
])

const toggleFavorite = (song) => {
  song.isFavorite = !song.isFavorite
}
</script>

<style scoped>
.home-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #4a47a3 0%, #413d6b 100%);
  color: white;
  padding: 0;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

/* 搜索栏样式 */
.search-bar {
  padding: 20px 16px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.search-input {
  border-radius: 20px;
}

.search-input :deep(.el-input__wrapper) {
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.search-input :deep(.el-input__inner) {
  color: white;
  font-size: 16px;
}

.search-input :deep(.el-input__inner::placeholder) {
  color: rgba(255, 255, 255, 0.7);
}

.search-input :deep(.el-input__prefix-inner) {
  color: rgba(255, 255, 255, 0.7);
}

/* 分类按钮样式 */
.category-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 20px;
  overflow-x: auto;
}

.category-btn {
  padding: 8px 16px;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  font-size: 14px;
  backdrop-filter: blur(10px);
}

.category-btn.active {
  background-color: #409eff;
  border-color: #409eff;
  color: white;
}

.category-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 歌曲列表样式 */
.song-list {
  padding: 0 16px;
  margin-bottom: 80px;
}

.song-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background-color 0.2s ease;
}

.song-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin: 0 -8px;
  padding: 12px 8px;
}

.song-rank {
  width: 40px;
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

.song-info {
  flex: 1;
  margin-left: 16px;
}

.song-title {
  font-size: 16px;
  font-weight: 500;
  color: white;
  margin-bottom: 4px;
  line-height: 1.2;
}

.song-artist {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.2;
}

.song-action {
  width: 40px;
  text-align: center;
}

.star-icon {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.2s ease;
}

.star-icon:hover {
  color: rgba(255, 255, 255, 0.8);
}

.star-icon.favorite {
  color: #ffd700;
}

/* 底部播放器控制条 */
.bottom-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-bar {
  width: 120px;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .home-page {
    font-size: 14px;
  }
  
  .search-bar {
    padding: 16px 12px 12px;
  }
  
  .category-tabs {
    padding: 0 12px 16px;
  }
  
  .song-list {
    padding: 0 12px;
  }
  
  .song-rank {
    width: 35px;
    font-size: 15px;
  }
  
  .song-info {
    margin-left: 12px;
  }
  
  .song-title {
    font-size: 15px;
  }
  
  .song-artist {
    font-size: 13px;
  }
}
</style> 